//
//  DDMoneybagHeaderView.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/10/13.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDMoneybagHeaderView.h"

@implementation DDMoneybagHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{

    self = [super initWithFrame:frame];

    if (self) {
     
        self.headView = [[UIView alloc]initWithFrame:frame];
        self.headView.backgroundColor = COLOR_FONT_LIGHT_GREEN;
        [self addSubview:self.headView];
        
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.text = @"账户余额（元）";
        titleLabel.font = [UIFont systemFontOfSize:15];
        titleLabel.textColor = [UIColor whiteColor];
        [self.headView addSubview:titleLabel];
        
        self.moneyLabel = [[UILabel alloc]init];
        self.moneyLabel.text = @"0.00";
        self.moneyLabel.font = [UIFont systemFontOfSize:47];
        self.moneyLabel.textColor = [UIColor whiteColor];
        [self.headView addSubview:self.moneyLabel];
        
        
        self.shareMoneyLabel = [[UILabel alloc]init];
        self.shareMoneyLabel.text = @"额外可用共享金额 : 0.00元";
        self.shareMoneyLabel.font = [UIFont systemFontOfSize:15];
        self.shareMoneyLabel.textColor = [UIColor whiteColor];
        [self.headView addSubview:self.shareMoneyLabel];
        
        WEAKSELF
        [titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
           
            make.top.mas_equalTo(weakSelf).offset(20);
            make.left.mas_equalTo(weakSelf).offset(25);
            make.right.mas_equalTo(weakSelf).offset(-25);
            make.height.equalTo(@(30));
        }];
        
        [self.shareMoneyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.mas_equalTo(weakSelf).offset(-20);
            make.left.right.mas_equalTo(titleLabel);
            make.height.equalTo(@(30));
        }];
        
        [self.moneyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(titleLabel.mas_bottom);
            make.left.right.mas_equalTo(titleLabel);
            make.bottom.mas_equalTo(self.shareMoneyLabel.mas_top);
        }];
        
    }
    return self;
}

- (void)setDataModel:(DDMoneybagHomepageModel *)dataModel
{
    self.moneyLabel.text = !dataModel.money?@"0.00":dataModel.money;
    self.shareMoneyLabel.text = [NSString stringWithFormat:@"额外可用共享金额 : %@元",!dataModel.share_money?@"0.00":dataModel.share_money];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
